/*
 * LDIR
 *
 * LDIR, a GPS cartography application built for Let's Do It Romania eco
 * campaign.
 * Copyright (C) 2010 Genera Software <office@generasoftware.com>
 *
 * http://generasoftware.com/
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */
#ifndef LDIRAPPUI_H
#define LDIRAPPUI_H

#include <aknviewappui.h>
#include "Interfaces.h"
#include "asynccommandhandler.h"

class CAknNavigationDecorator;
class CLDIRMainView;
class CLDIRWasteView;
class CLDIRMapView;
class CLDIRAboutView;
class CLDIRSplashView;
class CLDIRSettingsView;
class CLDIRListCacheView;
class CGPSLocator;
class CGPSPositionData;
class CWasteInfo;
class CWSEngine;
class CAknInfoPopupNoteController;

/**
 * @class    CLDIRAppUi LDIRAppUi.h
 * @brief The AppUi class handles application-wide aspects of the user interface, including
 *        view management and the default menu, control pane, and status pane.
 */
class CLDIRAppUi : public CAknViewAppUi,
	RAsyncCommandHandler<TInt> ,
	public MWsResponseHandler
	{
public:
	// constructor and destructor
	CLDIRAppUi();
	virtual ~CLDIRAppUi();
	void ConstructL();

public:
	// from CCoeAppUi
	TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );

	// from CEikAppUi
	void HandleCommandL( TInt aCommand );
	void HandleResourceChangeL( TInt aType );

	// from CAknAppUi
	void HandleViewDeactivation( const TVwsViewId& aViewIdToBeDeactivated,
		const TVwsViewId& aNewlyActivatedViewId );

	void HandlePositionUpdateL( const CGPSPositionData& aPositionData );
	void HandlePartialPositionUpdateL(
		const CGPSPositionData& aPartialPositionData );
	void HandlePositionQualityLossL();
	void HandlePositionTimedOutL();
	void HandlePositionErroL( TInt aError );
	void HandlePositionMethodL( const TDesC& aMethod );
	void ShowNoteL( const TDesC& aNote );
	TBool QueryUser( TInt aResId );

private:
	void InitializeContainersL();
	void InitializeEnginesL();
	void StartAddWasteViewL();
	void UploadCacheL();
	void GetUserSaltL();
	void ValidateUserL();
	void GetUserCredentialsL();
	/**
	 * Method to be implemented to handle a web services response.
	 *
	 * @param aRequestId - id of the request.
	 * @param aResponseStatus - the status returned by the web service(HTTP status).
	 * @param aResponse - json dom response.
	 */
	void HandleWsResponseL( TInt aRequestId, TInt aResponseStatus,
		CWsResponse* aResponse );
	/**
	 * Method to be implemeted to handle web services errors.
	 *
	 * @param aRequestId - id of the request.
	 * @param aErrorCode - the error code returned by the web service.
	 */
	virtual void HandleWsResponseErrorL( TInt aRequestId, TInt aErrorCode );

	void AsyncHandleCommandL( const TInt& aCommand );

	void HandleUploadResponseL( CWsResponse* aResponse );

private:
	CLDIRMainView* iLDIRMainView;
	CLDIRWasteView* iLDIRWasteView;
	CLDIRMapView* iLDIRMapView;
	CLDIRAboutView* iLDIRAboutView;
	CLDIRSplashView* iLDIRSplashView;
	CLDIRSettingsView* iLDIRSettingsView;
	CLDIRListCacheView* iLDIRListCacheView;
	CGPSLocator* iGpsLocator;
	CWSEngine* iWSEngine;
	CAknInfoPopupNoteController* iLdirNote;
	};

#endif // LDIRAPPUI_H
